<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="button" value="增加" id="btnadd">

    <script>
        //单击按钮增加文本框
        document.querySelector('#btnadd').onclick = function () {
            //写法一
            // var txt = document.createElement('input');
            // txt.type = 'text';
            // document.body.appendChild(txt);

            //写法二
            // document.write('<input type="text" name="name">');

            //写法三
            document.body.innerHTML += ('<input type="text" name="name">');
        }
    </script>
</body>

</html>